<?php

class postReplies {

    public $_string;
    public $_arrayPositive;
    public $_arrayNegative;
    private $_pointsPositive = 0;
    private $_pointsNegative = 0;

    function __construct($string) {
        $this->_string = $string;
    }

    private function positive() {
        foreach ($this->_arrayPositive as $key => $value) {
            $position = stripos($this->_string, $value);
            if ($position > 0) {
                $this->_pointsPositive++;
            }
        }
    }

    private function negative() {
        foreach ($this->_arrayNegative as $key => $value) {
            $position = stripos($this->_string, $value);
            if ($position > 0) {
                $this->_pointsNegative++;
            }
        }
    }

    public function run() {
        $this->positive();
        $this->negative();
        if ($this->_pointsPositive > $this->_pointsNegative) {
            return 'POSITIVE';
        } elseif ($this->_pointsPositive < $this->_pointsNegative) {
            return 'NEGATIVE';
        } else {
            return 'NEUTRAL';
        }
    }

}
?>
